<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Asset_main_cat_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function insert_data($data){
    	$this->db->query('call fam_categories_ins(?,?,?,?,@err,@msg)',$data);
    	$que = $this->db->query("SELECT @err as err,@msg as msg");
		$msg;
		$err;
		foreach ($que->result() as $keys) {
			$err = $keys->err;
			$msg = $keys->msg;
		}
		$arr = array(
			'err' => $err,
			'msg' => $msg,
		);
		return $arr;
    }

    public function update_data($data){
    	$this->db->query('call fam_categories_upd(?,?,?,?,@err,@msg)',$data);
    	$que = $this->db->query("SELECT @err as err,@msg as msg");
		$msg;
		$err;
		foreach ($que->result() as $keys) {
			$err = $keys->err;
			$msg = $keys->msg;
		}
		$arr = array(
			'err' => $err,
			'msg' => $msg,
		);
		return $arr;
    }

    public function search($code)
    {
    	return $this->db->query('SELECT * FROM fam_categories WHERE category_code LIKE "'.$code.'" ')->result();
    }

    public function getData($id){
    	$this->db->where('category_code',$id);
    	return $this->db->get('fam_categories')->result();
    }
}